<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./WEB-INF/templates/template.xhtml">

            <ui:define name="content">
                <h:form id="form">

                    <p:growl id="messages" showDetail="true" life="900"/>
                    <h:panelGroup rendered="#{tInventoryController.items.rowCount > 0}">
                        <h:outputText value="#{tInventoryController.pagination.pageFirstItem + 1}..#{tInventoryController.pagination.pageLastItem + 1}/#{tInventoryController.pagination.itemsCount}"/>&nbsp;
                        <h:commandLink action="#{tInventoryController.previous}" value="#{bundle.Previous} #{tInventoryController.pagination.pageSize}" rendered="#{tInventoryController.pagination.hasPreviousPage}"/>&nbsp;
                        <h:commandLink action="#{tInventoryController.next}" value="#{bundle.Next} #{tInventoryController.pagination.pageSize}" rendered="#{tInventoryController.pagination.hasNextPage}"/>&nbsp;
                        <p:dataTable var="item" value="#{tInventoryController.items}" id="items" editable="true" resizableColumns="true" paginator="false" sortMode="multiple">

                            <f:facet name="header">
                                Tire Inventory
                            </f:facet>

                            <p:ajax event="rowEdit" listener="#{tInventoryController.prepareEditt}" update=":form:messages" />
                            <p:ajax event="rowEditCancel" listener="#{tInventoryController.onCancel}" update=":form:messages" />

                            <p:column headerText="Inventory ID" sortBy="#{item.id}" style="width: 12%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.id}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.id}" />
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Unit ID" sortBy="#{item.unitId}" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.unitId}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.unitId}" label="Unit ID"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="Brand" sortBy="#{item.brand}" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.brand}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.brand}"  label="Brand"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Series" sortBy="#{item.series}" style="width: 6%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.series}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.series}"  label="Series"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Size" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.size1}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.size1}" label="Size"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Dot #" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.dotNumber}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.dotNumber}"  label="Dot #"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>

                            <p:column headerText="Vendor" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.vendor}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.vendor}"  label="Vendor"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Wheel Position" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.wheelPosition}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.wheelPosition}"  label="Wheel Position"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Purchase Price" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.purchasePrice}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.purchasePrice}"  label="Purchase Price"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Other Price" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.otherPrice}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.otherPrice}" label="Other Price"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="PO #" style="width: 10%; font-size: 12px">
                                <p:cellEditor>
                                    <f:facet name="output">
                                        <h:outputText value="#{item.poNumber}" />
                                    </f:facet>
                                    <f:facet name="input">
                                        <p:inputText value="#{item.poNumber}"  label="PO #"/>
                                    </f:facet>
                                </p:cellEditor>
                            </p:column>
                            <p:column headerText="Edit" style="width: 5%; font-size: 12px">
                                <p:rowEditor/>
                            </p:column>
                        </p:dataTable>
                    </h:panelGroup>
                    <p:commandButton value="Unit Quick View"  style="font-size: 12px" actionListener="#{dialogBean.viewInventory}" update=":form:messages"/>

                </h:form>

            </ui:define>

        </ui:composition>
        <p:dialog modal="true" id="statusDialog" widgetVar="statusDlg" closable="true" closeOnEscape="true">
            <h:outputText value="Unit View" />
            <p:dataTable var="item" value="#{tUnitsController.items}" emptyMessage="No Data Available."  paginator="true" rows="5" rowKey="id">
                <p:column headerText="ID" >
                    <h:outputText value="#{item.id}"/>
                </p:column>
                <p:column headerText="Make" >
                    <h:outputText value="#{item.make}" />
                </p:column>
                <p:column headerText="Model">
                    <h:outputText value="#{item.model}" />
                </p:column>
                <p:column headerText="Year">
                    <h:outputText value="#{item.year}" />
                </p:column>
                <p:column headerText="Orig Purchase Price">
                    <h:outputText value="#{item.origPurchasePrice}" />
                </p:column>
                <p:column headerText="Fuel Type">
                    <h:outputText value="#{item.fuelType}" />
                </p:column>
                <p:column headerText="Owner">
                    <h:outputText value="#{item.owner}" />
                </p:column>
                <p:column headerText="Operator">
                    <h:outputText value="#{item.operator}" />
                </p:column>
                <p:column headerText="Out of Service">
                    <h:outputText value="#{item.decommFlag}" />
                </p:column>
                <p:column headerText="PO #">
                    <h:outputText value="#{item.poNum}" />
                </p:column>
                <p:column headerText="Service #">
                    <h:outputText value="#{item.serviceNum}" />
                </p:column>

            </p:dataTable>
        </p:dialog>
    </body>
</html>
